package com.hospital.data.simulation.controller;

import com.hospital.common.base.Result;
import com.hospital.common.pojo.TPatientInfo;
import com.hospital.data.simulation.service.TPatientInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 患者信息管理接口
 * @author yhn
 * @version 1.0
 */
@RestController
@RequestMapping("/patientInfo")
public class PatientInfoController {
    @Autowired
    private TPatientInfoService patientInfoService;

    /**
     * 添加患者信息
     * @return 添加的患者信息ID
     */
    @PostMapping("/add")
    public Result<Long> addPatientInfo(@RequestBody TPatientInfo patientInfo){
        return Result.success(patientInfoService.addPatientInfo(patientInfo));
    }
    /**
     * 删除患者信息
     */
    @DeleteMapping("/delete")
    public Result<?> deletePatientInfo(@RequestParam("patientId") Long patientId){
        patientInfoService.deletePatientInfo(patientId);
        return Result.success();
    }
    /**
     * 更新患者信息
     * <br>
     * 需要提供患者信息的ID
     */
    @PostMapping("/update")
    public Result<?> updatePatientInfo(@RequestBody TPatientInfo patientInfo){
        patientInfoService.updatePatientInfo(patientInfo);
        return Result.success();
    }
}
